package com.example.bill.controller;

import com.example.area.service.AreaService;
import com.example.bill.service.BillService;
import com.example.bill.vo.BillVo;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import com.example.utils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bill")
public class billController {
    @Autowired
    BillService billService;
    /**
     * 收费管理-账单删除
     * @return
     */
    @GetMapping("/getBill")
    public CommonResult getBill(@RequestParam String billState, PageRequest pageRequest){
        MyPageHelper.StartPage(pageRequest);
        CommonResult commonResult = billService.getBill(billState);
        return commonResult;
    }
    /**
     * 收费管理-账单删除
     */
    @DeleteMapping("/delBill")
    public CommonResult delBill(Integer id){
        int i = billService.delBill(id);
        return CommonResult.ok(i);
    }
    /**
     * 收费管理-账单增改
     */
    @PostMapping("/saveOrUpdateBill")
    public CommonResult saveOrUpdateBill(@RequestBody BillVo billVo){
        int i = billService.saveOrUpdateBill(billVo);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }
}
